// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import VueRouter from 'vue-router'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios'
import Vuex from 'vuex'
import store from './store'

Vue.config.productionTip = false

Vue.use(VueRouter)
Vue.use(ElementUI)
Vue.use(Vuex)
Vue.prototype.axios=axios
//跨域
axios.defaults.baseURL = '/api'
axios.defaults.headers.post['Content-Type'] = 'application/json';

router.beforeEach((to,from,next)=>{
 let isLogin = sessionStorage.getItem('isLogin');
 if(to.path=='/logout'){
     sessionStorage.clear();
     //
     next({path:"/login"});
 }else if(to.path=='/login'){
    if(isLogin!=null){
      next({path:'/main/1111'});
    }
 }else if(isLogin==null){
    next({path:'/login'});
 }
 console.log("******"+from.path+"====>"+to.path);
 next()
 console.log("+++++++++++++++++++++");
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
